package com.atguigu.architecture;

import com.atguigu.pojo.WordCount;
import org.apache.flink.api.common.functions.FlatMapFunction;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.datastream.SingleOutputStreamOperator;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import org.apache.flink.util.Collector;

public class Flink02_OperatorChain {
    public static void main(String[] args) {
        Configuration conf = new Configuration();
        conf.setInteger("rest.port" , 5678);

        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment(conf);
        env.setParallelism(12);

        //全局禁用算子链
        //env.disableOperatorChaining();


        env.socketTextStream("hadoop102" , 9999)
                //.rebalance()
                //.keyBy( value -> value )
                //.shuffle()
                //.broadcast()
                // .global()
                //.forward()
                //.rebalance()
                .map( value -> value ).name("M1").setParallelism(2)//.disableChaining() // .startNewChain()
                .rescale()
                .map( value -> value ).name("M2").setParallelism(6)
                .print().setParallelism(1);

        try {
            env.execute();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
